package ObjectOriented;
/**
 * OverLoad 方法重载
 * 1. 方法名相同
 * 2. 参数列表不同（个数、类型、顺序）
 * 3. 方法重载的返回值类型通常是相同的
 */
public class OverLoad {
  private int a;
  private String b;

  public OverLoad() {
    this.a = 0;
    this.b = "";
  }
  public OverLoad(int a) {
    this.a = a;
    this.b = "";
  }
  public OverLoad(String b) {
    this.a = 0;
    this.b = b;
  }
  public OverLoad(int a, String b) {
    this.a = a;
    this.b = b;
  }
  public void show() {
    System.out.println("a: " + a + ", b: " + b);
  }

  public static void main(String[] args) {
    OverLoad obj1 = new OverLoad();
    obj1.show();
    OverLoad obj2 = new OverLoad(1);
    obj2.show();
    OverLoad obj3 = new OverLoad("hello");
    obj3.show();
    OverLoad obj4 = new OverLoad(2, "world");
    obj4.show();
  }
}
